package com.efast.dmom.mgmt.job;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.efast.cafe.commponent.job.base.AbstractStatefulJobBean;
import com.efast.cafe.commponent.job.bean.ScheduleExecuteLog;
import com.efast.cafe.commponent.log.ext.CafeLogger;
import com.efast.cafe.commponent.log.ext.CafeLoggerFactory;
import com.efast.cafe.framework.spring.SpringContextUtils;
import com.efast.dmom.mgmt.service.les.ImmediateReplenishmentJobService;



/**
 * 即时补货 : Immediate replenishment , 后台job，根据零件仓储关系里的配置自动执行；
 * 
 * 1:按照即时补货件的不同触发类型（请求/出库），计算出一个job周期内实际消耗了多少零件数，并且按照补货路径归类
 * 【1】：按请求：按照sps传给wms的kitting消耗算 . 【2】：按出库：按照wms实际出库记录算消耗
 * 
 * 2:按照路径分类逐个将对应零件的消耗数量增加至余数表（TW_BAS_PACK_SKU_QTY），余数表数量>=1箱时，产生补货需求（TW_INV_PAL_MRI）并且重置为余数表
 * 
 * 3:完成后需要将TE_KITTING_WMS_CONFIRM/TT_WHM_STOCK_OUTBOUND补货组织状态置为完成
 * 
 * @author ChenLipeng
 */
public class ImmediateReplenishmentJob extends AbstractStatefulJobBean {
	
	CafeLogger log = CafeLoggerFactory.getLogger(ImmediateReplenishmentJob.class);
	
	@Override
	protected void executeInternal(JobExecutionContext context,ScheduleExecuteLog cachelog) throws JobExecutionException {

		log.info("及时补货定时任务.................");
		// 补货任务需求 TW_INV_PAL_MRI
		ImmediateReplenishmentJobService immediateReplenishmentJobService = SpringContextUtils.getBean(ImmediateReplenishmentJobService.class);
		immediateReplenishmentJobService.execute();
		log.info("定时任务执行完毕--->及时补货定时任务.........");
	}

}